using GroupSix.Domain.Entity.App;

namespace GroupSix.Domain.Services;

/// <summary>
/// Token服务接口
/// </summary>
public interface ITokenService
{
    /// <summary>
    /// 生成JWT Token
    /// </summary>
    /// <param name="user">用户信息</param>
    /// <returns>JWT Token</returns>
    string GenerateToken(GsUser user);

    /// <summary>
    /// 异步生成JWT Token
    /// </summary>
    /// <param name="user">用户信息</param>
    /// <returns>JWT Token</returns>
    Task<string> GenerateTokenAsync(GsUser user);

    /// <summary>
    /// 验证Token有效性
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>是否有效</returns>
    bool ValidateToken(string token);

    /// <summary>
    /// 异步验证Token有效性
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>是否有效</returns>
    Task<bool> ValidateTokenAsync(string token);

    /// <summary>
    /// 从Token中获取用户ID
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>用户ID</returns>
    Guid? GetUserIdFromToken(string token);

    /// <summary>
    /// 将Token加入黑名单
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <param name="userId">用户ID</param>
    /// <param name="reason">登出原因</param>
    /// <returns>是否成功</returns>
    Task<bool> BlacklistTokenAsync(string token, Guid userId, string reason = "用户主动登出");

    /// <summary>
    /// 检查Token是否在黑名单中
    /// </summary>
    /// <param name="token">JWT Token</param>
    /// <returns>是否在黑名单中</returns>
    Task<bool> IsTokenBlacklistedAsync(string token);

    /// <summary>
    /// 强制登出用户的所有Token
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="reason">登出原因</param>
    /// <returns>是否成功</returns>
    Task<bool> ForceLogoutAllDevicesAsync(Guid userId, string reason = "强制登出所有设备");
} 